<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$api = $app->make(Dingo\Api\Routing\Router::class);
    
$api->version('v1', function ($api) {
    $api->group(['prefix' => 'v1'], function($api){
        // login
        $api->post('auth/login', ['uses' => 'App\Http\Controllers\Auth\AuthController@postLogin']);

        // QR apis
        $api->group(['prefix' => 'qr'], function()use($api){
            $api->get('get', ['uses' => 'App\Http\Controllers\QrController@get']);
            $api->post('ask', ['uses' => 'App\Http\Controllers\QrController@ask']);
            $api->post('qrLogin', [
                // 'middleware' => 'api.auth',
                'uses' => 'App\Http\Controllers\QrController@qrLogin',
            ]);
        });
        $api->group(['prefix' => 'es'], function()use($api){
            $api->get('job', ['uses' => 'App\Http\Controllers\EsController@jobList']);
            $api->get('seeker', ['uses' => 'App\Http\Controllers\EsController@seekerList']);
        });
        $api->group(['prefix' => 'newsf'], function()use($api){
            $api->get('listNews', ['uses' => 'App\Http\Controllers\NewsController@listNews']);
            $api->get('detail/{id}', ['uses' => 'App\Http\Controllers\NewsController@detail']);
        });
        $api->group(['prefix' => 'forget'], function()use($api){
            $api->post('sendCode', ['uses' => 'App\Http\Controllers\ForgetController@sendCode']);
            $api->post('checkCode', ['uses' => 'App\Http\Controllers\ForgetController@checkCode']);
            $api->post('checkCommitId', ['uses' => 'App\Http\Controllers\ForgetController@checkCommitId']);
            $api->post('forgetAndResetPwd', ['uses' => 'App\Http\Controllers\ForgetController@forgetAndResetPwd']);
        });

        $api->group(['prefix' => 'regist'], function()use($api){
            $api->post('verifyMobileOTP', ['uses' => 'App\Http\Controllers\RegistController@verifyCode']);
        });
        
        // access-api apis
        $api->group(['prefix' => 'access'], function()use($api){
            $api->get('accessList', ['uses' => 'App\Http\Controllers\AccessController@accessList']);
        }); 
        
        // needs jwt token 
        $api->group(['middleware' => 'api.auth'], function($api){
            // needs rbac access
            $api->group(['middleware' => 'rbac'], function($api){
                // authentic apis
                $api->group(['prefix' => 'auth'], function($api){
                    $api->get('user', ['uses' => 'App\Http\Controllers\Auth\AuthController@getUser']);
                    $api->patch('refresh', ['uses' => 'App\Http\Controllers\Auth\AuthController@patchRefresh']);
                    $api->delete('invalidate', ['uses' => 'App\Http\Controllers\Auth\AuthController@deleteInvalidate']);
                });

                // data-api apis
                $api->group(['prefix' => 'data'], function()use($api){
                    $api->get('listUser', ['uses' => 'App\Http\Controllers\UserController@listUser']);
                    $api->get('listCompany', ['uses' => 'App\Http\Controllers\CompanyController@listCompany']);
                });

                // news apis 
                $api->group(['prefix' => 'news'], function()use($api){
                    $api->get('listNews', ['uses' => 'App\Http\Controllers\NewsController@listNews']);
                    $api->get('detail/{id}', ['uses' => 'App\Http\Controllers\NewsController@detail']);
                    $api->post('add', ['uses' => 'App\Http\Controllers\NewsController@add']);
                    $api->post('edit', ['uses' => 'App\Http\Controllers\NewsController@edit']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\NewsController@delete']);
                    $api->put('publish', ['uses' => 'App\Http\Controllers\NewsController@publish']);
                    $api->put('draft', ['uses' => 'App\Http\Controllers\NewsController@draft']);
                });

                // new category apis
                $api->group(['prefix' => 'category'], function()use($api){
                    $api->get('listCategory', ['uses' => 'App\Http\Controllers\CategoryController@listCategory']);
                    $api->get('detail/{id}', ['uses' => 'App\Http\Controllers\CategoryController@detail']);
                    $api->post('add', ['uses' => 'App\Http\Controllers\CategoryController@add']);
                    $api->put('edit', ['uses' => 'App\Http\Controllers\CategoryController@edit']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\CategoryController@delete']);
                    $api->put('open', ['uses' => 'App\Http\Controllers\CategoryController@open']);
                    $api->put('close', ['uses' => 'App\Http\Controllers\CategoryController@close']);
                });

                // faq apis 
                $api->group(['prefix' => 'faq'], function()use($api){
                    $api->get('listFaq', ['uses' => 'App\Http\Controllers\FaqController@listFaq']);
                    $api->get('detail/{id}', ['uses' => 'App\Http\Controllers\FaqController@detail']);
                    $api->post('add', ['uses' => 'App\Http\Controllers\FaqController@add']);
                    $api->put('edit', ['uses' => 'App\Http\Controllers\FaqController@edit']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\FaqController@delete']);
                    $api->put('open', ['uses' => 'App\Http\Controllers\FaqController@open']);
                    $api->put('close', ['uses' => 'App\Http\Controllers\FaqController@close']);
                });

                // faq category
                $api->group(['prefix' => 'faqCate'], function()use($api){
                    $api->get('listCategory', ['uses' => 'App\Http\Controllers\FaqCategoryController@listCategory']);
                    $api->get('detail/{id}', ['uses' => 'App\Http\Controllers\FaqCategoryController@detail']);
                    $api->post('add', ['uses' => 'App\Http\Controllers\FaqCategoryController@add']);
                    $api->put('edit', ['uses' => 'App\Http\Controllers\FaqCategoryController@edit']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\FaqCategoryController@delete']);
                    $api->put('open', ['uses' => 'App\Http\Controllers\FaqCategoryController@open']);
                    $api->put('close', ['uses' => 'App\Http\Controllers\FaqCategoryController@close']);
                });

                // rbac node
                $api->group(['prefix' => 'rbacNode'], function()use($api){
                    $api->post('add', ['uses' => 'App\Http\Controllers\RbacNodeController@add']);
                    $api->put('edit', ['uses' => 'App\Http\Controllers\RbacNodeController@edit']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\RbacNodeController@delete']);
                    $api->get('list', ['uses' => 'App\Http\Controllers\RbacNodeController@listNodes']);
                    $api->get('detail', ['uses' => 'App\Http\Controllers\RbacNodeController@detail']);
                });
                // $api->get('getNavigation', ['uses' => 'App\Http\Controllers\RbacNodeController@getNavigation']);

                // rbac role
                $api->group(['prefix' => 'rbacRole'], function()use($api){
                    $api->post('add', ['uses' => 'App\Http\Controllers\RbacRoleController@add']);
                    $api->put('open', ['uses' => 'App\Http\Controllers\RbacRoleController@open']);
                    $api->put('close', ['uses' => 'App\Http\Controllers\RbacRoleController@close']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\RbacRoleController@delete']);
                    $api->get('list', ['uses' => 'App\Http\Controllers\RbacRoleController@listRole']);
                    $api->get('detail', ['uses' => 'App\Http\Controllers\RbacRoleController@detail']);
                    $api->get('access', ['uses' => 'App\Http\Controllers\RbacRoleController@access']);
                    $api->put('setAccess', ['uses' => 'App\Http\Controllers\RbacRoleController@setAccess']);
                });

                // rbac user
                $api->group(['prefix' => 'rbacUser'], function()use($api){
                    $api->post('add', ['uses' => 'App\Http\Controllers\RbacUserController@add']);
                    $api->put('open', ['uses' => 'App\Http\Controllers\RbacUserController@open']);
                    $api->put('close', ['uses' => 'App\Http\Controllers\RbacUserController@close']);
                    $api->get('detail', ['uses' => 'App\Http\Controllers\RbacUserController@detail']);
                    $api->delete('delete', ['uses' => 'App\Http\Controllers\RbacUserController@delete']);
                    $api->get('list', ['uses' => 'App\Http\Controllers\RbacUserController@listUser']);
                    $api->put('initPassword', ['uses' => 'App\Http\Controllers\RbacUserController@initPassword']);
                    $api->put('modifyPass', ['uses' => 'App\Http\Controllers\RbacUserController@modifyPassword']);
                    $api->put('saveProfile', ['uses' => 'App\Http\Controllers\RbacUserController@saveProfile']);
                });
            });
        });
    });
});

